#include "qMeasureDialog.h"
#include "ui_qMeasureDialog.h"

qMeasureDialog* g_mDialog = NULL;

qMeasureDialog::qMeasureDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::qMeasureDialog)
{
    ui->setupUi(this);
    QRect rect = parent->geometry();
    int x = rect.x() + 20;
    int y = rect.y() + 100;
    this->move(x, y);

    g_mDialog = this;
}

qMeasureDialog::~qMeasureDialog()
{
    delete ui;
}

IClosureNotifyMMsg* qMeasureDialog::getClosureNotifyMMsg()
{
    return &in;
}

void qMeasureDialog::slotNotifyResult(QString str)
{
    QLabel* lb = this->findChild<QLabel*>("label", Qt::FindChildrenRecursively);
    lb->setText(str);
}

void qMeasureDialog::closeEvent()
{
    hide();
}

void qMeasureDialog::ClosureNotifyMMsg::notify(char *msg)
{
    QString measureMsg = msg;
    //qMeasureDialog *parent = (qMeasureDialog *) ((char*)this - offsetof(qMeasureDialog, in));
    g_mDialog->slotNotifyResult(measureMsg);
}
